package com.io;

import org.apache.commons.io.IOUtils;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class InputStreamTest {
    public static void main(String[] args) {
        InputStream is = null;
        try {
            is = new FileInputStream("/Users/edy/Desktop/file1/1.txt");
            byte[] bytes = new byte[1024];
            int len;
            while ((len = is.read(bytes)) > 0 ) {
                System.out.println(new String(bytes,0,len));
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            IOUtils.closeQuietly(is);
        }
    }
}
